<?php

//读取帖子信息细节
 function getpostdetail($postid){
	$ds 	= Dataservice::getInstance();
	$res 	= $ds->getpostdetail($postid);
	$res	= json_decode($res);
	$status =  $res[0]->status;
	$detail = @$res[1]->info;
	if($status == 'fail'){
		return false;
	}else if($status == 'success'){
		return $detail;
	}
}

//读取帖子信息细节
 function getreplydetail($id){
	$ds 	 = Dataservice::getInstance();
	$res 	 = $ds->getreplydetail($id);
	$res 	 = json_decode($res);
	return $res;
}

//裁剪函数
function cleardir(){
	$dir = "../images/tmp/";
	$dp = opendir($dir);
	while(($file = readdir($dp)) != false){
		//var_dump($dir.$file);
		chmod($dir.$file,0755);
		@unlink($dir.$file);
	}
	closedir($dp); 
	//return 1;
}		

//取得输入时间与当前时间差
function gettimediff($inputtime){
	$inputstamp = strtotime($inputtime);
	$nowstamp   = mktime();
	$timediff = ($nowstamp - $inputstamp);
	if($timediff < 60){
		$result = '刚刚';
	}else if(($temp = $timediff/60)<60){
		$result = floor($temp)." 分前";
	}else if(($temp = $temp/60) <24){
        $result = floor($temp)." 小时前";
    }else if(($temp = $temp/24) <30){
        $result = floor($temp)." 天前";
    }else if(($temp = $temp/30) <12){
        $result = floor($temp)." 月前";
    }else{
        $temp = $temp/12;
       $result = floor($temp)." 年前";
    }
    return $result;
}

?>